home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 August / CICA - The Ultimate Collection of Shareware for Windows (Disc 2) (August 1995).iso / disc2 / demo / pwrtcp11.exe / TELNET.FR_ / TELNET.bin
Text File  |  1995-02-16  |  9KB  |  283 lines

  1. VERSION 2.00
  2. Begin Form frmTelnet 
  3.    BackColor       =   &H00000000&
  4.    Caption         =   "PowerTCP VT220"
  5.    ClientHeight    =   5820
  6.    ClientLeft      =   3132
  7.    ClientTop       =   2628
  8.    ClientWidth     =   7368
  9.    Height          =   6468
  10.    Icon            =   TELNET.FRX:0000
  11.    Left            =   3084
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5820
  14.    ScaleWidth      =   7368
  15.    Top             =   2028
  16.    Width           =   7464
  17.    Begin PowerTCP_TNT TNT1 
  18.       Flags           =   0
  19.       Left            =   600
  20.       LocalDotAddr    =   ""
  21.       OemLicense      =   ""
  22.       RemoteHost      =   ""
  23.       RemotePort      =   23
  24.       Top             =   1980
  25.    End
  26.    Begin PowerTCP_VT VT1 
  27.       Align           =   1  'Align Top
  28.       BackColor       =   &H00FFFFFF&
  29.       FontBold        =   0   'False
  30.       FontItalic      =   0   'False
  31.       FontName        =   "VT220_ascii"
  32.       FontSize        =   12
  33.       Height          =   1452
  34.       Left            =   0
  35.       OemLicense      =   ""
  36.       TabIndex        =   0
  37.       Top             =   0
  38.       Width           =   7368
  39.    End
  40.    Begin Menu mnuConnect 
  41.       Caption         =   "&Connect"
  42.       Begin Menu mnuCRemoteSystem 
  43.          Caption         =   "&Remote System..."
  44.       End
  45.       Begin Menu mnuCDisconnect 
  46.          Caption         =   "&Disconnect"
  47.          Enabled         =   0   'False
  48.       End
  49.       Begin Menu mnuCSep 
  50.          Caption         =   "-"
  51.       End
  52.       Begin Menu mnuCExit 
  53.          Caption         =   "E&xit"
  54.       End
  55.    End
  56.    Begin Menu mnuEdit 
  57.       Caption         =   "&Edit"
  58.       Begin Menu mnuECopy 
  59.          Caption         =   "&Copy"
  60.       End
  61.       Begin Menu mnuEPaste 
  62.          Caption         =   "&Paste"
  63.       End
  64.    End
  65.    Begin Menu mnuOptions 
  66.       Caption         =   "&Options"
  67.       Begin Menu mnuOLocalEcho 
  68.          Caption         =   "&Local Echo"
  69.       End
  70.    End
  71.    Begin Menu mnuHelp 
  72.       Caption         =   "&Help"
  73.       Begin Menu mnuHHowToUse 
  74.          Caption         =   "&How to Use Telnet"
  75.       End
  76.       Begin Menu mnuHSep 
  77.          Caption         =   "-"
  78.       End
  79.       Begin Menu mnuHAbout 
  80.          Caption         =   "&About Telnet..."
  81.       End
  82.    End
  83. End
  84.  
  85. ' IMPORTANT: We MUST use the API MessageBox function
  86. ' instead of the VB MsgBox function. See the PowerTCP
  87. ' README for more information.
  88. Declare Function MessageBox Lib "User" (ByVal hWnd As Integer, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Integer) As Integer
  89.  
  90.  
  91. Declare Sub ShellAbout Lib "SHELL.DLL" (ByVal hWnd As Integer, ByVal AppName As String, ByVal AppInfo As String, ByVal hIcon As Integer)
  92.  
  93. ' Show parameters
  94. Const MODAL = 1
  95. Const MODELESS = 0
  96.  
  97. ' MsgBox parameters
  98. Const MB_OK = 0                 ' OK button only
  99.  
  100. Sub CenterForm (frmParent As Form, frmChild As Form)
  101. ' This procedure centers a form over another form.
  102. ' Calling this routine loads the dialog. Use the Show method
  103. ' to display the dialog after calling this routine ( ie MyFrm.Show 1)
  104.  
  105. Dim l, t
  106.   ' get left offset
  107.   l = frmParent.Left + ((frmParent.Width - frmChild.Width) / 2)
  108.   If (l + frmChild.Width > screen.Width) Then
  109.     l = screen.Width = frmChild.Width
  110.   End If
  111.  
  112.   ' get top offset
  113.   t = frmParent.Top + ((frmParent.Height - frmChild.Height) / 2)
  114.   If (t + frmChild.Height > screen.Height) Then
  115.     t = screen.Height - frmChild.Height
  116.   End If
  117.  
  118.   ' center the child formfv
  119.   frmChild.Move l, t
  120.  
  121. End Sub
  122.  
  123. Sub Form_Load ()
  124.     VT1.Enabled = True
  125. End Sub
  126.  
  127. Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  128.     mnuCExit_Click
  129. End Sub
  130.  
  131. Sub Form_Resize ()
  132.     VT1.Height = ScaleHeight + screen.TwipsPerPixelX
  133. End Sub
  134.  
  135. Sub Form_Unload (Cancel As Integer)
  136.     End
  137. End Sub
  138.  
  139. Sub mnuCDisconnect_Click ()
  140.     Me.Caption = "PowerTCP VT220"
  141.     TNT1.Action = CLOSECOMM
  142. End Sub
  143.  
  144. Sub mnuCExit_Click ()
  145.     ' Disconnect, and do a DoEvents for the connection
  146.     ' to finish closing (it will not close instantaneously).
  147.     TNT1.Action = CLOSECOMM
  148.     DoEvents
  149.  
  150.     End
  151. End Sub
  152.  
  153. Sub mnuCRemoteSystem_Click ()
  154.     CenterForm frmTelnet, frmConnect
  155.     frmConnect.Show MODAL
  156. End Sub
  157.  
  158. Sub mnuECopy_Click ()
  159.     ' Copy selected text to Clipboard.
  160.     ClipBoard.Clear
  161.     ClipBoard.SetText Mid$(VT1.Text, VT1.SelStart, VT1.SelLength)
  162. End Sub
  163.  
  164. Sub mnuEPaste_Click ()
  165.     ' Place text from Clipboard into VT1.
  166.     TNT1.Send = ClipBoard.GetText()
  167. End Sub
  168.  
  169. Sub mnuHAbout_Click ()
  170.     ShellAbout 0, App.Title, "Version 1.0" & Chr$(10) & "Copyright ⌐ 1994 Dart Communications", Me.Icon
  171. End Sub
  172.  
  173. Sub mnuHHowToUse_Click ()
  174.     Msg$ = "This application will connect to another"
  175.     Msg$ = Msg$ + " computer using the TELNET protocol."
  176.     Msg$ = Msg$ + "  This application is a Telnet"
  177.     Msg$ = Msg$ + " client."
  178.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Telnet: Page 1/4", 0)
  179.     Msg$ = "To connect to a Telnet host, choose"
  180.     Msg$ = Msg$ + " Connect... from the File menu. Enter"
  181.     Msg$ = Msg$ + " the name of the remote computer and"
  182.     Msg$ = Msg$ + " select a default port or type a port"
  183.     Msg$ = Msg$ + " number, and click OK. The default port"
  184.     Msg$ = Msg$ + " is telnet, number 23."
  185.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Telnet: Page 2/4", 0)
  186.     Msg$ = "Once you are connected,"
  187.     Msg$ = Msg$ + " any text you type or paste into the"
  188.     Msg$ = Msg$ + " text area is sent to the remote"
  189.     Msg$ = Msg$ + " host. All text received from the"
  190.     Msg$ = Msg$ + " host is displayed in the text area."
  191.     Msg$ = Msg$ + Chr$(10) & Chr$(10) & "To disconnect"
  192.     Msg$ = Msg$ + " from the host, choose Disconnect"
  193.     Msg$ = Msg$ + " from the File menu."
  194.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Telnet: Page 3/4", 0)
  195.     Msg$ = "Technical note: This"
  196.     Msg$ = Msg$ + " client program uses Dart's VT-220"
  197.     Msg$ = Msg$ + " custom control to emulate a VT-220"
  198.     Msg$ = Msg$ + ". This control can be licensed and used by"
  199.     Msg$ = Msg$ + " others to build emulation packages."
  200.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Telnet: Page 4/4", 0)
  201. End Sub
  202.  
  203. Sub mnuOLocalEcho_Click ()
  204.     mnuOLocalEcho.Checked = Not (mnuOLocalEcho.Checked)
  205. End Sub
  206.  
  207. Sub TNT1_Cmd (Cmd As Integer, TelnetOption As Integer, SubOption As String)
  208.     Dim MySubOption As String * 6
  209.     Select Case Cmd
  210.     Case SB_CMD
  211.         ' negotiate TermType suboption
  212.         If TelnetOption = 24 Then
  213.             MySubOption = Chr$(0) & "vt220"
  214.             i = Len(MySubOption)
  215.             TNT1.SubOption = MySubOption
  216.             TNT1.DoSubOption = 24
  217.         ElseIf TelnetOption = WINDOW_SIZE Then
  218.             Dim Columns As Integer
  219.             SubOpt = Chr$(0) & Chr$(80) & Chr$(0) & Chr$(24)
  220.             TNT1.SubOption = SubOpt
  221.             TNT1.DoSubOption = WINDOW_SIZE
  222.         End If
  223.     Case DO_CMD
  224.         If TelnetOption = 24 Then
  225.             ' want to subnegotiate TermType
  226.             TNT1.WillOption = 24
  227.         ElseIf TelnetOption = WINDOW_SIZE Then
  228.             TNT1.WillOption = WINDOW_SIZE
  229.         Else
  230.             TNT1.WontOption = TelnetOption
  231.         End If
  232.     Case DONT_CMD
  233.         If TelnetOption <> 1 Then
  234.             TNT1.WontOption = TelnetOption
  235.         End If
  236.         
  237.     Case WILL_CMD
  238.         If TelnetOption = 3 Then
  239.             ' do suppress go-aheads
  240.             TNT1.DoOption = 3
  241.         ElseIf TelnetOption = 1 Then
  242.             ' do echo characters sent
  243.             TNT1.DoOption = 1
  244.         Else
  245.             TNT1.DontOption = TelnetOption
  246.         End If
  247.     Case WONT_CMD
  248.         TNT1.DontOption = TelnetOption
  249.     End Select
  250. End Sub
  251.  
  252. Sub TNT1_Connect ()
  253.     mnuCRemoteSystem.Enabled = False
  254.     mnuCDisconnect.Enabled = True
  255.     Me.Caption = "PowerTCP VT220 - " & Format$(TNT1.RemoteHost)
  256. End Sub
  257.  
  258. Sub TNT1_Recv (RecvData As String)
  259.     If Len(RecvData) = 0 Then
  260.         mnuCRemoteSystem.Enabled = True
  261.         mnuCDisconnect.Enabled = False
  262.     Else
  263.         ' Place the received characters into the VT-220 emulator
  264.         VT1.Display = RecvData
  265.     End If
  266. End Sub
  267.  
  268. Sub VT1_KeyPress (KeyString As String)
  269.     ' Make sure the user is connected, or else don't
  270.     ' display the character
  271.     If TNT1.State <> CONNECTED Then
  272.         Exit Sub
  273.     End If
  274.     
  275.     ' Send the character to the host
  276.     TNT1.Send = KeyString
  277.  
  278.     ' If the LocalEcho menu option is checked, then
  279.     ' we should display it locally as well.
  280.     If mnuOLocalEcho.Checked = True Then VT1.Display = KeyString
  281. End Sub
  282.  
  283.